$(function(){

        $("#modalDialogWindow").dialog({
        resizable: true,
        width: 640,
        modal: true,
        show: 'slide',
        minHeight: 200,
//        hide: 'clip',
        autoOpen: false,
        closeOnEscape: false,
close: function(event, ui) {

}
    });


});
var modalWindowHandler = new dynamicModalWindowHandler();
function dynamicModalWindowHandler()
{
this.contentType = null;
this.contentTypeParameters = null;
this.loadedModalContent = null;
this.AJAXCallbackFunction = null;
  this.setModalWindowTitle = function(dialogTitle)
  {
if (dialogTitle != null)
{
    $( "#modalDialogWindow" ).dialog( "option", "title", dialogTitle );
}

  }

  this.setWindowPosition =function(position)
  {
      $( "#modalDialogWindow" ).dialog( "option", "position", position );
  }

  this.setWindowWidth = function (width)
  {
      if (width != null)
          {
           $( "#modalDialogWindow" ).dialog({width: width});
          }

  }


  this.setContent = function (contentType)
  {
      this.contentType = contentType;
  }

  this.setContentTypeParameters = function(contentTypeParameters)
  {
   this.contentTypeParameters= contentTypeParameters;
  }

  this.setAJAXCallbackFunction = function(AJAXCAllBackFunction)
  {
this.AJAXCallbackFunction = AJAXCAllBackFunction;
  }

  this.openModalWindow = function ()
  {
     $( "#modalDialogWindow" ).children("#modalWindowContent").html("<div style='margin-top : 50px; text-align: center; vertical-align: middle; height: 100%;'><img src="+$('#loadingImage').val()+" align='middle' alt='Loading Pic is Missing' /></div>");
     $( "#modalDialogWindow" ).dialog('open');
     sendRequest.setAction(this.contentType);
     if (this.contentTypeParameters == null)
         {
            sendRequest.setSendParameters({});
         }
         else
             {
               sendRequest.setSendParameters(this.contentTypeParameters);
             }


     $("#mask").load(sendRequest.serverURL,sendRequest.getSendData(),function (commentatorContent)
{
  $( "#modalDialogWindow" ).children("#modalWindowContent").html("<div style='margin-top : 50px; text-align: center; vertical-align: middle; height: 100%;'><img src="+$('#loadingImage').val()+" align='middle' alt='Loading Pic is Missing' /></div>");
$( "#modalDialogWindow" ).children("#modalWindowContent").hide();
$( "#modalDialogWindow" ).children("#modalWindowContent").delay(500).html($("#mask").html()).fadeIn('slow');
$("#mask").empty();


});

  }
    
}